package test4;

public class BankAccount {
    private int balance;

    public BankAccount(){
        this.balance=0;
    }

    public BankAccount(int balance){
        if(balance<0){
            this.balance=0;
        }else {
            this.balance = balance;
        }
    }

    public int getBlance() {
        return balance;
    }

    public int withdraw(int amount){
        int balance=this.balance-amount;
        if(balance<0){
            System.out.println("账户余额不足\n" +
                    "账户的初始余额是:"+this.balance);
            return this.balance ;
        }
        return this.balance-=amount;
    }

    public int deposit(int amount){
         return this.balance+=amount;
    }

}
